/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tv.facturacion.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import tv.global.modelo.Moneda;
import tv.global.modelo.Sucursal;
import tv.inventario.modelo.Deposito;
import tv.inventario.modelo.Producto;
import tv.inventario.modelo.Sector;
import tv.venta.modelo.Cliente;

/**
 *
 * @author ctrosch
 */
@Entity
@Table(name = "FCRMVI",  schema = "dbo")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "USR_FCRMVI_TIPITM", discriminatorType = DiscriminatorType.STRING, length = 1)
public abstract class ItemMovimientoFacturacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ItemMovimientoFacturacionPK itemMovimientoVentaPK;
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_TIPPRO", referencedColumnName = "STMPDH_TIPPRO", nullable = false, insertable=true, updatable=true),
        @JoinColumn(name = "FCRMVI_ARTCOD", referencedColumnName = "STMPDH_ARTCOD", nullable = false, insertable=true, updatable=true)
    })
    @ManyToOne(optional=false)
    private Producto producto;
    
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_MODFOR", referencedColumnName = "FCRMVH_MODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_CODFOR", referencedColumnName = "FCRMVH_CODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_NROFOR", referencedColumnName = "FCRMVH_NROFOR", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne
    MovimientoFacturacion movimiento;
   
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_MODAPL", referencedColumnName = "FCRMVH_MODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_CODAPL", referencedColumnName = "FCRMVH_CODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_NROAPL", referencedColumnName = "FCRMVH_NROFOR", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne
    MovimientoFacturacion movimientoAplicacion;

    @Column(name = "FCRMVI_MODCPT", length = 2)
    private String modcpt;
    @Column(name = "FCRMVI_TIPCPT")
    private Character tipcpt;
    @Column(name = "FCRMVI_CODCPT", length = 6)
    private String codcpt;
    //Tipo de producto original
    @Column(name = "FCRMVI_TIPORI", length = 6)
    private String tipori;
    //Codigo de producto original
    @Column(name = "FCRMVI_ARTORI", length = 30)
    private String artori;
    //Numero de Serie
    @Column(name = "FCRMVI_NSERIE", length = 30)
    private String nserie;
    //Numero de despacho
    @Column(name = "FCRMVI_NDESPA", length = 30)
    private String ndespa;
    //Numero de envase
    @Column(name = "FCRMVI_ENVASE", length = 30)
    private String envase;
    //Numero otros
    @Column(name = "FCRMVI_NOTROS", length = 30)
    private String notros;
    //Numero de atributo
    @Column(name = "FCRMVI_NATRIB", length = 30)
    private String natrib;
    //Numero de estante
    @Column(name = "FCRMVI_NESTAN", length = 30)
    private String nestan;
    //Numero de ubicacion
    @Column(name = "FCRMVI_NUBICA", length = 30)
    private String nubica;
    //Fecha
    @Column(name = "FCRMVI_NFECHA", length = 30)
    private String nfecha;    
    @Column(name = "FCRMVI_TSERIE", length = 30)
    private String tserie;
    @Column(name = "FCRMVI_TDESPA", length = 30)
    private String tdespa;
    @Column(name = "FCRMVI_TENVAS", length = 30)
    private String tenvas;
    @Column(name = "FCRMVI_TOTROS", length = 30)
    private String totros;
    @Column(name = "FCRMVI_TATRIB", length = 30)
    private String tatrib;
    @Column(name = "FCRMVI_TESTAN", length = 30)
    private String testan;
    @Column(name = "FCRMVI_TUBICA", length = 30)
    private String tubica;
    @Column(name = "FCRMVI_TFECHA", length = 30)
    private String tfecha;

    //Deposito
    @JoinColumn(name = "FCRMVI_DEPOSI", referencedColumnName = "STTDEH_DEPOSI", nullable = true)
    @ManyToOne(optional=false)
    private Deposito deposito;

    //Sector
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_DEPOSI", referencedColumnName = "STTDEI_DEPOSI", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_SECTOR", referencedColumnName = "STTDEI_SECTOR", nullable = false)
    })
    @ManyToOne
    private Sector sector;


    //Sucursal o punto de venta
    @JoinColumn(name = "FCRMVI_SUCURS", referencedColumnName = "GRTSUC_SUCURS", nullable = false)
    @ManyToOne
    private Sucursal sucursal;

    //Cliente
    @JoinColumn(name = "FCRMVI_NROCTA", referencedColumnName = "VTMCLH_NROCTA", nullable = false)
    @ManyToOne(optional = false)
    private Cliente cliente;

    @Column(name = "FCRMVI_NROSUB", length = 13)
    private String nrosub;

    @Column(name = "FCRMVI_OLDPRE", precision = 20, scale = 4)
    private BigDecimal oldpre;
    @Column(name = "FCRMVI_NEWPRE", precision = 20, scale = 4)
    private BigDecimal newpre;
    @Column(name = "FCRMVI_PRECIO", precision = 20, scale = 4)
    private BigDecimal precio;
    @Column(name = "FCRMVI_CANTID", precision = 18, scale = 4)    
    private BigDecimal cantid;
    @Column(name = "FCRMVI_FACSEC", precision = 12, scale = 4)
    private BigDecimal facsec;
    @Column(name = "FCRMVI_CNTSEC", precision = 18, scale = 4)
    private BigDecimal cntsec;
    @Column(name = "FCRMVI_UNIMED", length = 6)
    private String unimed;
    @Column(name = "FCRMVI_UNISEC", length = 6)
    private String unisec;
    @Column(name = "FCRMVI_TIPUNI", length = 1)
    private String tipuni;
    @Column(name = "FCRMVI_UNIFAC", length = 6)
    private String unifac;
    @Column(name = "FCRMVI_FACFAC", precision = 12, scale = 4)
    private BigDecimal facfac;
    @Column(name = "FCRMVI_CNTFAC", precision = 18, scale = 4)
    private BigDecimal cntfac;
    @Column(name = "FCRMVI_UNIALT", length = 6)
    private String unialt;
    @Column(name = "FCRMVI_FACALT", precision = 12, scale = 4)
    private BigDecimal facalt;
    @Column(name = "FCRMVI_CNTALT", precision = 18, scale = 4)
    private BigDecimal cntalt;
    @Column(name = "FCRMVI_UNICON", length = 6)
    private String unicon;
    @Column(name = "FCRMVI_FACCON", precision = 12, scale = 4)
    private BigDecimal faccon;
    @Column(name = "FCRMVI_CNTCON", precision = 18, scale = 4)
    private BigDecimal cntcon;
    @Column(name = "FCRMVI_FCHENT")
    @Temporal(TemporalType.DATE)
    private Date fchent;
    @Column(name = "FCRMVI_FCHHAS")
    @Temporal(TemporalType.DATE)
    private Date fchhas;
    @Column(name = "FCRMVI_PCTBF1", precision = 15, scale = 4)
    private BigDecimal pctbf1;
    @Column(name = "FCRMVI_PCTBF2", precision = 15, scale = 4)
    private BigDecimal pctbf2;
    @Column(name = "FCRMVI_PCTBF3", precision = 15, scale = 4)
    private BigDecimal pctbf3;
    @Column(name = "FCRMVI_PCTBF4", precision = 15, scale = 4)
    private BigDecimal pctbf4;
    @Column(name = "FCRMVI_PCTBF5", precision = 15, scale = 4)
    private BigDecimal pctbf5;
    @Column(name = "FCRMVI_PCTBF6", precision = 15, scale = 4)
    private BigDecimal pctbf6;
    @Column(name = "FCRMVI_PCTBF7", precision = 15, scale = 4)
    private BigDecimal pctbf7;
    @Column(name = "FCRMVI_PCTBF8", precision = 15, scale = 4)
    private BigDecimal pctbf8;
    @Column(name = "FCRMVI_PCTBF9", precision = 15, scale = 4)
    private BigDecimal pctbf9;
    @Column(name = "FCRMVI_PCTBFN", precision = 15, scale = 4)
    private BigDecimal pctbfn;
    @Lob
    @Column(name = "FCRMVI_TEXTOS", length = 2147483647)
    private String textos;
    @Column(name = "FCRMVI_CNTPEN", precision = 18, scale = 4)
    private BigDecimal fcrmviCntpen;
    @Column(name = "FCRMVI_MODORI", length = 2)
    private String modori;
    @Column(name = "FCRMVI_CODORI", length = 6)
    private String codori;
    @Column(name = "FCRMVI_NROORI")
    private Integer nroori;
    @Column(name = "FCRMVI_ITMORI")
    private Integer itmori;
    @Column(name = "FCRMVI_EXPORI", length = 2)
    private String expori;
    @Column(name = "FCRMVI_CNTBON", precision = 18, scale = 4)
    private BigDecimal cntbon;
    @Column(name = "FCRMVI_CUENTA", length = 40)
    private String cuenta;
    @Column(name = "FCRMVI_CNTANT", precision = 18, scale = 4)
    private BigDecimal cntant;
    @Column(name = "FCRMVI_PORANT", precision = 15, scale = 4)
    private BigDecimal porant;
    @Column(name = "FCRMVI_ARTEQU", length = 60)
    private String artequ;
    @Column(name = "FCRMVI_CANTST", precision = 18, scale = 4)
    private BigDecimal cantst;
    @Column(name = "FCRMVI_CNTORI", precision = 18, scale = 4)
    private BigDecimal cntori;
    @Column(name = "FCRMVI_MCDAPL", length = 2)
    private String mcdapl;
    @Column(name = "FCRMVI_CCDAPL", length = 6)
    private String ccdapl;
    @Column(name = "FCRMVI_DEPTRA", length = 15)
    private String deptra;
    @Column(name = "FCRMVI_SECTRA", length = 15)
    private String sectra;
    @Column(name = "FCRMVI_MODINI", length = 2)
    private String modini;
    @Column(name = "FCRMVI_CODINI", length = 6)
    private String codini;
    @Column(name = "FCRMVI_NROINI")
    private Integer nroini;
    @Column(name = "FCRMVI_ITMINI")
    private Integer itmini;
    @Column(name = "FCRMVI_NIVINI", length = 2)
    private String nivini;
    //Moneda ultima compra
    @JoinColumn(name = "FCRMVI_COFLIS", referencedColumnName = "GRTCOF_CODCOF", nullable = false)
    @ManyToOne
    private Moneda monedaListaPrecio;
    

    @Column(name = "FCRMVI_CAMBIO", precision = 20, scale = 4)
    private BigDecimal cambio;
    @Column(name = "FCRMVI_MODGAN", length = 2)
    private String modgan;
    @Column(name = "FCRMVI_CODGAN", length = 6)
    private String codgan;
    @Column(name = "FCRMVI_NROGAN")
    private Integer nrogan;
    @Column(name = "FCRMVI_CNTVAR", precision = 18, scale = 4)
    private BigDecimal cntvar;
    @Column(name = "FCRMVI_CNTUNI", precision = 18, scale = 4)
    private BigDecimal cntuni;
    @Column(name = "FCRMVI_FACTOR", precision = 12, scale = 4)
    private BigDecimal factor;
    @Column(name = "FCRMVI_NCNPNA")
    private Character ncnpna;
    @Column(name = "FCRMVI_NGENPN")
    private Character ngenpn;
    @Column(name = "FCRMVI_NCANPN")
    private Character ncanpn;
    @Column(name = "FCRMVI_NGENST")
    private Character ngenst;
    @Column(name = "FCRMVI_PRESEC", precision = 20, scale = 4)
    private BigDecimal presec;
    @Column(name = "FCRMVI_TIPOPR", length = 6)
    private String tipopr;
    @Column(name = "FCRMVI_CODOPR", length = 30)
    private String codopr;
    @Column(name = "FCRMVI_CODEMP", length = 10)
    private String codemp;
    @Column(name = "FCRMVI_EMPAPL", length = 10)
    private String empapl;
    @Column(name = "FCRMVI_EMPGAN", length = 10)
    private String empgan;
    @Column(name = "FCRMVI_EMPINI", length = 10)
    private String empini;
    @Column(name = "FCRMVI_EMPORI", length = 10)
    private String empori;
    @Column(name = "FCRMVI_PCTCOM", precision = 15, scale = 4)
    private BigDecimal pctcom;
    @Column(name = "FCRMVI_MODOST", length = 2)
    private String modost;
    @Column(name = "FCRMVI_CODOST", length = 6)
    private String codost;
    @Column(name = "FCRMVI_NROOST")
    private Integer nroost;
    @Column(name = "FCRMVI_ITMOST")
    private Integer itmost;
    @Column(name = "FCRMVI_EXPOST", length = 2)
    private String expost;
    @Column(name = "FCRMVI_EMPOST", length = 10)
    private String empost;
    @Column(name = "FCRMVI_PRENAC", precision = 20, scale = 4)
    private BigDecimal prenac;
    @Column(name = "FCRMVI_PREEXT", precision = 20, scale = 4)
    private BigDecimal preext;
    @Column(name = "FCRMVI_PREUSS", precision = 20, scale = 4)
    private BigDecimal preuss;

    //Total de linea
    @Column(name = "FCRMVI_TOTLIN", precision = 15, scale = 4)
    private BigDecimal totlin;

    @Column(name = "FCRMVI_FECALT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecalt;
    @Column(name = "FCRMVI_FECMOD")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecmod;
    @Column(name = "FCRMVI_USERID", length = 15)
    private String userid;
    @Column(name = "FCRMVI_ULTOPR")
    private Character ultopr;
    @Column(name = "FCRMVI_OALIAS", length = 10)
    private String oalias;

    @Column(name = "USR_FCRMVI_ORIGEN", length = 1)
    private String origen;

    //Indica si el item fue dado de baja
    @Column(name = "FCRMVI_DEBAJA")
    private Character debaja;

    @Transient
    private BigDecimal pendiente;

    @Transient
    private BigDecimal precioListaConIVA;

    @Transient
    private BigDecimal precioFinalConIVA;

    @Transient
    private BigDecimal precioFinalSinIVA;

    @Transient
    private BigDecimal totalPendienteSinIVA;

    @Transient
    private BigDecimal totalPendienteConIVA;

    @Transient
    private BigDecimal totalLineaSinIVA;

    @Transient
    private BigDecimal totalLineaConIVA;



    public ItemMovimientoFacturacion() {
        oldpre = BigDecimal.ZERO;
        newpre = BigDecimal.ZERO;
        facsec = BigDecimal.ZERO;
        cntsec = BigDecimal.ZERO;
        facfac = BigDecimal.ZERO;
        pctbf2 = BigDecimal.ZERO;
        pctbf3 = BigDecimal.ZERO;
        pctbf4 = BigDecimal.ZERO;
        pctbf5 = BigDecimal.ZERO;
        pctbf6 = BigDecimal.ZERO;
        pctbf7 = BigDecimal.ZERO;
        pctbf8 = BigDecimal.ZERO;
        pctbf9 = BigDecimal.ZERO;
        cntbon = BigDecimal.ZERO;
        cntalt = BigDecimal.ZERO;
        cntant = BigDecimal.ZERO;
        porant = BigDecimal.ZERO;
        cambio = BigDecimal.ZERO;
        cntvar = BigDecimal.ZERO;
        cntuni = BigDecimal.ZERO;
        factor = BigDecimal.ZERO;
        preext = BigDecimal.ZERO;
        preuss = BigDecimal.ZERO;
        ncnpna = 'N';
        codopr = "";
        codemp = "TEM";
        empapl = "TEM";
        empini = "TEM";
        empori = "TEM";
        debaja = 'N';
        fecalt = new Date();
        fecmod = new Date();
        ultopr = 'A';
        userid = "ADMIN";
        oalias = "FCRMVI";
        
        //Seteamos por defecto origen web
        origen = "W";
        
    }

    public ItemMovimientoFacturacion(ItemMovimientoFacturacionPK idPK) {
        this.itemMovimientoVentaPK = idPK;
        oldpre = BigDecimal.ZERO;
        newpre = BigDecimal.ZERO;
        facsec = BigDecimal.ZERO;
        cntsec = BigDecimal.ZERO;
        facfac = BigDecimal.ZERO;
        pctbf2 = BigDecimal.ZERO;
        pctbf3 = BigDecimal.ZERO;
        pctbf4 = BigDecimal.ZERO;
        pctbf5 = BigDecimal.ZERO;
        pctbf6 = BigDecimal.ZERO;
        pctbf7 = BigDecimal.ZERO;
        pctbf8 = BigDecimal.ZERO;
        pctbf9 = BigDecimal.ZERO;
        cntbon = BigDecimal.ZERO;
        cntalt = BigDecimal.ZERO;
        cntant = BigDecimal.ZERO;
        porant = BigDecimal.ZERO;
        cambio = BigDecimal.ZERO;
        cntvar = BigDecimal.ZERO;
        cntuni = BigDecimal.ZERO;
        factor = BigDecimal.ZERO;
        preext = BigDecimal.ZERO;
        preuss = BigDecimal.ZERO;
        ncnpna = 'N';
        codopr = "";
        codemp = "TEM";
        empapl = "TEM";
        empini = "TEM";
        empori = "TEM";
        debaja = 'N';
        fecalt = new Date();
        fecmod = new Date();
        ultopr = 'A';
        userid = "ADMIN";
        oalias = "FCRMVI";

        //Seteamos por defecto origen web
        origen = "W";
        

        if(idPK!=null){
            modori = idPK.getModfor();
            codori = idPK.getCodfor();
            nroori = idPK.getNrofor();
            itmori = idPK.getNroitm();
            expori = idPK.getExpapl();
            modini = idPK.getModfor();
            codini = idPK.getCodfor();
            nroini = idPK.getNrofor();
            itmini = idPK.getNroitm();
            nivini = idPK.getExpapl();
        }
    }

    public ItemMovimientoFacturacion(ItemMovimientoFacturacionPK idPK, Producto producto) {
        this.itemMovimientoVentaPK = idPK;
        this.producto = producto;
        oldpre = BigDecimal.ZERO;
        newpre = BigDecimal.ZERO;
        facsec = BigDecimal.ZERO;
        cntsec = BigDecimal.ZERO;
        facfac = BigDecimal.ZERO;
        pctbf2 = BigDecimal.ZERO;
        pctbf3 = BigDecimal.ZERO;
        pctbf4 = BigDecimal.ZERO;
        pctbf5 = BigDecimal.ZERO;
        pctbf6 = BigDecimal.ZERO;
        pctbf7 = BigDecimal.ZERO;
        pctbf8 = BigDecimal.ZERO;
        pctbf9 = BigDecimal.ZERO;
        cntbon = BigDecimal.ZERO;
        cntalt = BigDecimal.ZERO;
        cntant = BigDecimal.ZERO;
        porant = BigDecimal.ZERO;
        cambio = BigDecimal.ZERO;
        cntvar = BigDecimal.ZERO;
        cntuni = BigDecimal.ZERO;
        factor = BigDecimal.ZERO;
        preext = BigDecimal.ZERO;
        preuss = BigDecimal.ZERO;
        ncnpna = 'N';
        codopr = "";
        codemp = "TEM";
        empapl = "TEM";
        empini = "TEM";
        empori = "TEM";
        debaja = 'N';
        fecalt = new Date();
        fecmod = new Date();
        ultopr = 'A';
        userid = "ADMIN";
        oalias = "FCRMVI";

        //Seteamos por defecto origen web
        origen = "W";
        
        if(producto!=null){
            tipori = producto.getProductoPK().getTippro();
            artori = producto.getProductoPK().getArtcod();
            tipcpt = producto.getTipcpt();
            modcpt = producto.getModcpt();
            codcpt = producto.getCodcpt();
            cuenta = producto.getCuenvt();
            
        }

        if(idPK!=null){
            modori = idPK.getModfor();
            codori = idPK.getCodfor();
            nroori = idPK.getNrofor();
            itmori = idPK.getNroitm();
            expori = idPK.getExpapl();
            modini = idPK.getModfor();
            codini = idPK.getCodfor();
            nroini = idPK.getNrofor();
            itmini = idPK.getNroitm();
            nivini = idPK.getExpapl();
        }
    }

    public String getArtequ() {
        return artequ;
    }

    public void setArtequ(String artequ) {
        this.artequ = artequ;
    }

    public String getArtori() {
        return artori;
    }

    public void setArtori(String artori) {
        this.artori = artori;
    }

    public BigDecimal getCambio() {
        return cambio;
    }

    public void setCambio(BigDecimal cambio) {
        this.cambio = cambio;
    }

    public BigDecimal getCantid() {
        return cantid;
    }

    public void setCantid(BigDecimal cantid) {
        this.cantid = cantid;
        if(cantid!=null){
            cntfac = cantid;
            cntalt = cantid;
            cntcon = cantid;
        }
    }

    public BigDecimal getCantst() {
        return cantst;
    }

    public void setCantst(BigDecimal cantst) {
        this.cantst = cantst;
    }

    public String getCcdapl() {
        return ccdapl;
    }

    public void setCcdapl(String ccdapl) {
        this.ccdapl = ccdapl;
    }

    public BigDecimal getCntalt() {
        return cntalt;
    }

    public void setCntalt(BigDecimal cntalt) {
        this.cntalt = cntalt;
    }

    public BigDecimal getCntant() {
        return cntant;
    }

    public void setCntant(BigDecimal cntant) {
        this.cntant = cntant;
    }

    public BigDecimal getCntbon() {
        return cntbon;
    }

    public void setCntbon(BigDecimal cntbon) {
        this.cntbon = cntbon;
    }

    public BigDecimal getCntcon() {
        return cntcon;
    }

    public void setCntcon(BigDecimal cntcon) {
        this.cntcon = cntcon;
    }

    public BigDecimal getCntfac() {
        return cntfac;
    }

    public void setCntfac(BigDecimal cntfac) {
        this.cntfac = cntfac;
    }

    public BigDecimal getCntori() {
        return cntori;
    }

    public void setCntori(BigDecimal cntori) {
        this.cntori = cntori;
    }

    public BigDecimal getCntsec() {
        return cntsec;
    }

    public void setCntsec(BigDecimal cntsec) {
        this.cntsec = cntsec;
    }

    public BigDecimal getCntuni() {
        return cntuni;
    }

    public void setCntuni(BigDecimal cntuni) {
        this.cntuni = cntuni;
    }

    public BigDecimal getCntvar() {
        return cntvar;
    }

    public void setCntvar(BigDecimal cntvar) {
        this.cntvar = cntvar;
    }

    public String getCodcpt() {
        return codcpt;
    }

    public void setCodcpt(String codcpt) {
        this.codcpt = codcpt;
    }

    public String getCodemp() {
        return codemp;
    }

    public void setCodemp(String codemp) {
        this.codemp = codemp;
    }

    public String getCodgan() {
        return codgan;
    }

    public void setCodgan(String codgan) {
        this.codgan = codgan;
    }

    public String getCodini() {
        return codini;
    }

    public void setCodini(String codini) {
        this.codini = codini;
    }

    public String getCodopr() {
        return codopr;
    }

    public void setCodopr(String codopr) {
        this.codopr = codopr;
    }

    public String getCodori() {
        return codori;
    }

    public void setCodori(String codori) {
        this.codori = codori;
    }

    public String getCodost() {
        return codost;
    }

    public void setCodost(String codost) {
        this.codost = codost;
    }

    public Moneda getMonedaListaPrecio() {
        return monedaListaPrecio;
    }

    public void setMonedaListaPrecio(Moneda monedaListaPrecio) {
        this.monedaListaPrecio = monedaListaPrecio;
    }
    

    public String getCuenta() {
        return cuenta;
    }

    public void setCuenta(String cuenta) {
        this.cuenta = cuenta;
    }

    public Character getDebaja() {
        return debaja;
    }

    public void setDebaja(Character debaja) {
        this.debaja = debaja;
    }

    public Deposito getDeposito() {
        return deposito;
    }

    public void setDeposito(Deposito deposito) {
        this.deposito = deposito;
    }

    public Sector getSector() {
        return sector;
    }

    public void setSector(Sector sector) {
        this.sector = sector;
    }
    
    public String getDeptra() {
        return deptra;
    }

    public void setDeptra(String deptra) {
        this.deptra = deptra;
    }

    public String getEmpapl() {
        return empapl;
    }

    public void setEmpapl(String empapl) {
        this.empapl = empapl;
    }

    public String getEmpgan() {
        return empgan;
    }

    public void setEmpgan(String empgan) {
        this.empgan = empgan;
    }

    public String getEmpini() {
        return empini;
    }

    public void setEmpini(String empini) {
        this.empini = empini;
    }

    public String getEmpori() {
        return empori;
    }

    public void setEmpori(String empori) {
        this.empori = empori;
    }

    public String getEmpost() {
        return empost;
    }

    public void setEmpost(String empost) {
        this.empost = empost;
    }

    public String getEnvase() {
        return envase;
    }

    public void setEnvase(String envase) {
        this.envase = envase;
    }

    public String getExpori() {
        return expori;
    }

    public void setExpori(String expori) {
        this.expori = expori;
    }

    public String getExpost() {
        return expost;
    }

    public void setExpost(String expost) {
        this.expost = expost;
    }

    public BigDecimal getFacalt() {
        return facalt;
    }

    public void setFacalt(BigDecimal facalt) {
        this.facalt = facalt;
    }

    public BigDecimal getFaccon() {
        return faccon;
    }

    public void setFaccon(BigDecimal faccon) {
        this.faccon = faccon;
    }

    public BigDecimal getFacfac() {
        return facfac;
    }

    public void setFacfac(BigDecimal facfac) {
        this.facfac = facfac;
    }

    public BigDecimal getFacsec() {
        return facsec;
    }

    public void setFacsec(BigDecimal facsec) {
        this.facsec = facsec;
    }

    public BigDecimal getFactor() {
        return factor;
    }

    public void setFactor(BigDecimal factor) {
        this.factor = factor;
    }

    public Date getFchent() {
        return fchent;
    }

    public void setFchent(Date fchent) {
        this.fchent = fchent;
    }

    public Date getFchhas() {
        return fchhas;
    }

    public void setFchhas(Date fchhas) {
        this.fchhas = fchhas;
    }

    public BigDecimal getFcrmviCntpen() {
        return fcrmviCntpen;
    }

    public void setFcrmviCntpen(BigDecimal fcrmviCntpen) {
        this.fcrmviCntpen = fcrmviCntpen;
    }

    public ItemMovimientoFacturacionPK getItemMovimientoVentaPK() {
        return itemMovimientoVentaPK;
    }

    public void setItemMovimientoVentaPK(ItemMovimientoFacturacionPK idPK) {

        this.itemMovimientoVentaPK = idPK;

        if(idPK!=null){
            modori = idPK.getModfor();
            codori = idPK.getCodfor();
            nroori = idPK.getNrofor();
            itmori = idPK.getNroitm();
            expori = idPK.getExpapl();
            modini = idPK.getModfor();
            codini = idPK.getCodfor();
            nroini = idPK.getNrofor();
            itmini = idPK.getNroitm();
            nivini = idPK.getExpapl();
        }
    }

    public Integer getItmini() {
        return itmini;
    }

    public void setItmini(Integer itmini) {
        this.itmini = itmini;
    }

    public Integer getItmori() {
        return itmori;
    }

    public void setItmori(Integer itmori) {
        this.itmori = itmori;
    }

    public Integer getItmost() {
        return itmost;
    }

    public void setItmost(Integer itmost) {
        this.itmost = itmost;
    }

    public String getMcdapl() {
        return mcdapl;
    }

    public void setMcdapl(String mcdapl) {
        this.mcdapl = mcdapl;
    }

    public String getModcpt() {
        return modcpt;
    }

    public void setModcpt(String modcpt) {
        this.modcpt = modcpt;
    }

    public String getModgan() {
        return modgan;
    }

    public void setModgan(String modgan) {
        this.modgan = modgan;
    }

    public String getModini() {
        return modini;
    }

    public void setModini(String modini) {
        this.modini = modini;
    }

    public String getModori() {
        return modori;
    }

    public void setModori(String modori) {
        this.modori = modori;
    }

    public String getModost() {
        return modost;
    }

    public void setModost(String modost) {
        this.modost = modost;
    }

    public MovimientoFacturacion getMovimiento() {
        return movimiento;
    }

    public void setMovimiento(MovimientoFacturacion movimiento) {
        this.movimiento = movimiento;
    }

    public String getNatrib() {
        return natrib;
    }

    public void setNatrib(String natrib) {
        this.natrib = natrib;
    }

    public Character getNcanpn() {
        return ncanpn;
    }

    public void setNcanpn(Character ncanpn) {
        this.ncanpn = ncanpn;
    }

    public Character getNcnpna() {
        return ncnpna;
    }

    public void setNcnpna(Character ncnpna) {
        this.ncnpna = ncnpna;
    }

    public String getNdespa() {
        return ndespa;
    }

    public void setNdespa(String ndespa) {
        this.ndespa = ndespa;
    }

    public String getNestan() {
        return nestan;
    }

    public void setNestan(String nestan) {
        this.nestan = nestan;
    }

    public BigDecimal getNewpre() {
        return newpre;
    }

    public void setNewpre(BigDecimal newpre) {
        this.newpre = newpre;
    }

    public String getNfecha() {
        return nfecha;
    }

    public void setNfecha(String nfecha) {
        this.nfecha = nfecha;
    }

    public Character getNgenpn() {
        return ngenpn;
    }

    public void setNgenpn(Character ngenpn) {
        this.ngenpn = ngenpn;
    }

    public Character getNgenst() {
        return ngenst;
    }

    public void setNgenst(Character ngenst) {
        this.ngenst = ngenst;
    }

    public String getNivini() {
        return nivini;
    }

    public void setNivini(String nivini) {
        this.nivini = nivini;
    }

    public String getNotros() {
        return notros;
    }

    public void setNotros(String notros) {
        this.notros = notros;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
        if(cliente!=null){
            nrosub = cliente.getNrocta();
        }
    }
    
    public Integer getNrogan() {
        return nrogan;
    }

    public void setNrogan(Integer nrogan) {
        this.nrogan = nrogan;
    }

    public Integer getNroini() {
        return nroini;
    }

    public void setNroini(Integer nroini) {
        this.nroini = nroini;
    }

    public Integer getNroori() {
        return nroori;
    }

    public void setNroori(Integer nroori) {
        this.nroori = nroori;
    }

    public Integer getNroost() {
        return nroost;
    }

    public void setNroost(Integer nroost) {
        this.nroost = nroost;
    }

    public String getNrosub() {
        return nrosub;
    }

    public void setNrosub(String nrosub) {
        this.nrosub = nrosub;
    }

    public String getNserie() {
        return nserie;
    }

    public void setNserie(String nserie) {
        this.nserie = nserie;
    }

    public String getNubica() {
        return nubica;
    }

    public void setNubica(String nubica) {
        this.nubica = nubica;
    }

    public BigDecimal getOldpre() {
        return oldpre;
    }

    public void setOldpre(BigDecimal oldpre) {
        this.oldpre = oldpre;
    }

    public BigDecimal getPctbf1() {
        return pctbf1;
    }

    public void setPctbf1(BigDecimal pctbf1) {
        this.pctbf1 = pctbf1;
    }

    public BigDecimal getPctbf2() {
        return pctbf2;
    }

    public void setPctbf2(BigDecimal pctbf2) {
        this.pctbf2 = pctbf2;
    }

    public BigDecimal getPctbf3() {
        return pctbf3;
    }

    public void setPctbf3(BigDecimal pctbf3) {
        this.pctbf3 = pctbf3;
    }

    public BigDecimal getPctbf4() {
        return pctbf4;
    }

    public void setPctbf4(BigDecimal pctbf4) {
        this.pctbf4 = pctbf4;
    }

    public BigDecimal getPctbf5() {
        return pctbf5;
    }

    public void setPctbf5(BigDecimal pctbf5) {
        this.pctbf5 = pctbf5;
    }

    public BigDecimal getPctbf6() {
        return pctbf6;
    }

    public void setPctbf6(BigDecimal pctbf6) {
        this.pctbf6 = pctbf6;
    }

    public BigDecimal getPctbf7() {
        return pctbf7;
    }

    public void setPctbf7(BigDecimal pctbf7) {
        this.pctbf7 = pctbf7;
    }

    public BigDecimal getPctbf8() {
        return pctbf8;
    }

    public void setPctbf8(BigDecimal pctbf8) {
        this.pctbf8 = pctbf8;
    }

    public BigDecimal getPctbf9() {
        return pctbf9;
    }

    public void setPctbf9(BigDecimal pctbf9) {
        this.pctbf9 = pctbf9;
    }

    public BigDecimal getPctbfn() {
        return pctbfn;
    }

    public void setPctbfn(BigDecimal pctbfn) {
        this.pctbfn = pctbfn;
    }

    public BigDecimal getPctcom() {
        return pctcom;
    }

    public void setPctcom(BigDecimal pctcom) {
        this.pctcom = pctcom;
    }

    public BigDecimal getPorant() {
        return porant;
    }

    public void setPorant(BigDecimal porant) {
        this.porant = porant;
    }

    public BigDecimal getPrecio() {
        return precio;
    }

    public void setPrecio(BigDecimal precio) {
        this.precio = precio;
    }

    public BigDecimal getPreext() {
        return preext;
    }

    public void setPreext(BigDecimal preext) {
        this.preext = preext;
    }

    public BigDecimal getPrenac() {
        return prenac;
    }

    public void setPrenac(BigDecimal prenac) {
        this.prenac = prenac;
    }

    public BigDecimal getPresec() {
        return presec;
    }

    public void setPresec(BigDecimal presec) {
        this.presec = presec;
    }

    public BigDecimal getPreuss() {
        return preuss;
    }

    public void setPreuss(BigDecimal preuss) {
        this.preuss = preuss;
    }

    public Producto getProducto() {
        return producto;
    }

    public void setProducto(Producto producto) {
        this.producto = producto;

        if(producto!=null){
            tipori = producto.getProductoPK().getTippro();
            artori = producto.getProductoPK().getArtcod();
            tipcpt = producto.getTipcpt();
            modcpt = producto.getModcpt();
            codcpt = producto.getCodcpt();
            cuenta = producto.getCuenvt();
            
        }
        
    } 

    public String getSectra() {
        return sectra;
    }

    public void setSectra(String sectra) {
        this.sectra = sectra;
    }

    public Sucursal getSucursal() {
        return sucursal;
    }

    public void setSucursal(Sucursal sucursal) {
        this.sucursal = sucursal;
    }
    
    public String getTatrib() {
        return tatrib;
    }

    public void setTatrib(String tatrib) {
        this.tatrib = tatrib;
    }

    public String getTdespa() {
        return tdespa;
    }

    public void setTdespa(String tdespa) {
        this.tdespa = tdespa;
    }

    public String getTenvas() {
        return tenvas;
    }

    public void setTenvas(String tenvas) {
        this.tenvas = tenvas;
    }

    public String getTestan() {
        return testan;
    }

    public void setTestan(String testan) {
        this.testan = testan;
    }

    public String getTextos() {
        return textos;
    }

    public void setTextos(String textos) {
        this.textos = textos;
    }

    public String getTfecha() {
        return tfecha;
    }

    public void setTfecha(String tfecha) {
        this.tfecha = tfecha;
    }

    public Character getTipcpt() {
        return tipcpt;
    }

    public void setTipcpt(Character tipcpt) {
        this.tipcpt = tipcpt;
    }

    public String getTipopr() {
        return tipopr;
    }

    public void setTipopr(String tipopr) {
        this.tipopr = tipopr;
    }

    public String getTipori() {
        return tipori;
    }

    public void setTipori(String tipori) {
        this.tipori = tipori;
    }

    public String getTipuni() {
        return tipuni;
    }

    public void setTipuni(String tipuni) {
        this.tipuni = tipuni;
    }

    public BigDecimal getTotlin() {
        return totlin;
    }

    public void setTotlin(BigDecimal totlin) {
        this.totlin = totlin;
    }

    public String getTotros() {
        return totros;
    }

    public void setTotros(String totros) {
        this.totros = totros;
    }

    public String getTserie() {
        return tserie;
    }

    public void setTserie(String tserie) {
        this.tserie = tserie;
    }

    public String getTubica() {
        return tubica;
    }

    public void setTubica(String tubica) {
        this.tubica = tubica;
    }

    public String getUnialt() {
        return unialt;
    }

    public void setUnialt(String unialt) {
        this.unialt = unialt;
    }

    public String getUnicon() {
        return unicon;
    }

    public void setUnicon(String unicon) {
        this.unicon = unicon;
    }

    public String getUnifac() {
        return unifac;
    }

    public void setUnifac(String unifac) {
        this.unifac = unifac;
    }

    public String getUnimed() {
        return unimed;
    }

    public void setUnimed(String unimed) {
        this.unimed = unimed;
    }

    public String getUnisec() {
        return unisec;
    }

    public void setUnisec(String unisec) {
        this.unisec = unisec;
    }

    public MovimientoFacturacion getMovimientoAplicacion() {
        return movimientoAplicacion;
    }

    public void setMovimientoAplicacion(MovimientoFacturacion movimientoAplicacion) {
        this.movimientoAplicacion = movimientoAplicacion;
    }

    public Date getFecalt() {
        return fecalt;
    }

    public void setFecalt(Date fecalt) {
        this.fecalt = fecalt;
    }

    public Date getFecmod() {
        return fecmod;
    }

    public void setFecmod(Date fecmod) {
        this.fecmod = fecmod;
    }

    public String getOalias() {
        return oalias;
    }

    public void setOalias(String oalias) {
        this.oalias = oalias;
    }

    public Character getUltopr() {
        return ultopr;
    }

    public void setUltopr(Character ultopr) {
        this.ultopr = ultopr;
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public BigDecimal getPendiente() {
        return pendiente;
    }

    public void setPendiente(BigDecimal pendiente) {
        this.pendiente = pendiente;
    }

    public String getOrigen() {
        return origen;
    }

    public void setOrigen(String origen) {
        this.origen = origen;
    }
    
    public BigDecimal getTotalPendienteConIVA() {

        try {
            totalPendienteConIVA = BigDecimal.ZERO;                        
            if (pendiente != null) {

                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);
                BigDecimal impTotal = pendiente.multiply(impUnit);
                
                if (codcpt.equals("V001")) {
                    totalPendienteConIVA = impTotal.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    totalPendienteConIVA = impTotal.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    totalPendienteConIVA = impTotal;
                }
            }

            return totalPendienteConIVA;
        } catch (Exception e) {
             
             return BigDecimal.ZERO;
        }
    }

    public void setTotalPendienteConIVA(BigDecimal totalPendienteConIVA) {
        this.totalPendienteConIVA = totalPendienteConIVA;
    }

    public BigDecimal getTotalPendienteSinIVA() {

        try {
            totalPendienteSinIVA = BigDecimal.ZERO;

            if (pendiente != null) {
                totalPendienteSinIVA = pendiente.multiply(precio.add(precio.multiply(pctbfn.divide(new BigDecimal(100)))));
            }
            return totalPendienteSinIVA;
        } catch (Exception e) {
            e.printStackTrace();
            return BigDecimal.ZERO;
        }
    }

    public void setTotalPendienteSinIVA(BigDecimal totalPendienteSinIVA) {
        this.totalPendienteSinIVA = totalPendienteSinIVA;
    }

    public BigDecimal getTotalLineaConIVA() {

        try {
            if (cantid != null) {

                totalLineaConIVA = BigDecimal.ZERO;
                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);
                BigDecimal impTotal = cantid.multiply(impUnit);

            
                if (codcpt.equals("V001")) {
                    totalLineaConIVA = impTotal.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    totalLineaConIVA = impTotal.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    totalLineaConIVA = impTotal;
                }
            }

            return totalLineaConIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }
    }

    public void setTotalLineaConIVA(BigDecimal totalLineaConIVA) {
        this.totalLineaConIVA = totalLineaConIVA;
    }

    public BigDecimal getTotalLineaSinIVA() {

        try {
            totalLineaSinIVA = BigDecimal.ZERO;

            if (cantid != null) {
                totalLineaSinIVA = cantid.multiply(precio.add(precio.multiply(pctbfn.divide(new BigDecimal(100)))));
            }
            return totalLineaSinIVA;
        } catch (Exception e) {
            return BigDecimal.ZERO;
        }

    }

    public void setTotalLineaSinIVA(BigDecimal totalLineaSinIVA) {
        this.totalLineaSinIVA = totalLineaSinIVA;
    }

    public BigDecimal getPrecioListaConIVA() {
        try {
            if (precio != null) {

                precioListaConIVA = BigDecimal.ZERO;

                if (codcpt.equals("V001")) {
                    precioListaConIVA = precio.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    precioListaConIVA = precio.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    precioListaConIVA = precio;
                }
            }

            return precioListaConIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }

    }

    public void setPrecioListaConIVA(BigDecimal precioListaConIVA) {
        this.precioListaConIVA = precioListaConIVA;
    }

    public BigDecimal getPrecioFinalConIVA() {
        try {
            if (precio != null) {

                precioFinalConIVA = BigDecimal.ZERO;
                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);

                if (codcpt.equals("V001")) {
                    precioFinalConIVA = impUnit.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    precioFinalConIVA = impUnit.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    precioFinalConIVA = impUnit;
                }
            }

            return precioFinalConIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }
    }

    public void setPrecioFinalConIVA(BigDecimal precioFinalConIVA) {
        this.precioFinalConIVA = precioFinalConIVA;
    }
    
    public BigDecimal getPrecioFinalSinIVA() {

        try {
            if (precio != null) {
                
                precioFinalSinIVA = BigDecimal.ZERO;
                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);
                precioFinalSinIVA = impUnit;
            }

            return precioFinalSinIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }
    }

    public void setPrecioFinalSinIVA(BigDecimal precioFinalSinIVA) {
        this.precioFinalSinIVA = precioFinalSinIVA;
    }

    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemMovimientoVentaPK != null ? itemMovimientoVentaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemMovimientoFacturacion)) {
            return false;
        }
        ItemMovimientoFacturacion other = (ItemMovimientoFacturacion) object;
        if ((this.itemMovimientoVentaPK == null && other.itemMovimientoVentaPK != null) || (this.itemMovimientoVentaPK != null && !this.itemMovimientoVentaPK.equals(other.itemMovimientoVentaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tv.venta.modelo.ItemMovimientoVenta[itemMovimientoVentaPK=" + itemMovimientoVentaPK + "]";
    }

}
